package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.math.BigDecimal;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.come.bean.LoginResult;
import org.come.until.Util;

import com.tool.btn.FactionBtn;
import com.tool.btn.FormsOnOffBtn;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;



/**
 * 帮派守护神修炼面板 编号:106
 * 
 * @author HGC<br>
 * @time 2020年1月15日 下午12:02:14<br>
 * @class 类名:FactionAngelPracticeJpanel<br>
 */
public class FactionAngelPracticeJpanel extends JPanel {

    private JLabel labLvl, labUpLvl, labNeedExp, labHaveExp, labNeedGoog, labHaveGoog;

    private FactionBtn btnPractice;

    private BigDecimal money = new BigDecimal(100000);
    private int menuType = -1;

    public FactionAngelPracticeJpanel() {
    		setPreferredSize(new Dimension(363, 304));
            setOpaque(false);
            setLayout(null);

            // 关闭按钮事件
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 106);
            offBtn.setBounds(363 - 37, 10, 25, 25);
            this.add(offBtn);

        getLabHaveExp();
        getLabHaveGoog();
        getLabLvl();
        getLabNeedExp();
        getLabNeedGoog();
        getLabUpLvl();
        getBtnPractice();

    }

    /** 展示面板 */
    public void showPanel(int type) {
        menuType = type;
        // 小成消耗 200W 金钱 经验 300 贡献
        // 大成消耗 500W 金钱 经验 1500 贡献
        if (menuType == 1) {// 小成修炼
            btnPractice.setText("小成修炼");
            money = new BigDecimal(2000000);
            labNeedExp.setText("2000000");
            labNeedGoog.setText("300");
        } else if (menuType == 2) {// 大成修炼
            btnPractice.setText("大成修炼");
            labNeedExp.setText("5000000");
            money = new BigDecimal(5000000);
            labNeedGoog.setText("1500");
        }
        showMessage();
    }

    // 等级上限 小成30点 大成60点
    // 小成满30级 才能修炼大成
    public void showMessage() {
        LoginResult loginResult = RoleData.getRoleData().getLoginResult();
        if (menuType == 1) {
            int extraPointInt = loginResult.getExtraPointInt("X");
            labLvl.setText(String.valueOf(extraPointInt));
            labUpLvl.setText(String.valueOf(30 - extraPointInt));
        } else if (menuType == 2) {
            int extraPointInt = loginResult.getExtraPointInt("D");
            labLvl.setText(String.valueOf(extraPointInt));
            labUpLvl.setText(String.valueOf(60 - extraPointInt));
        }
        labHaveExp.setText(loginResult.getExperience().toString());
        labHaveGoog.setText(loginResult.getContribution().toString());
    }

    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponent(g);
        	if (icon == null) {
                icon = new ImageIcon("inkImg/old/background/S175.png");
            }
            g.drawImage(icon.getImage(), 0, 0, 363, 304, null);
            Util.drawMoney(g, 188, 230);
            if (money != null) {
                Util.drawPrice(g, money, 188, 206);
            }
    }

    public JLabel getLabLvl() {
        if (labLvl == null) {
            labLvl = new JLabel();
            	labLvl.setBounds(167, 29, 40, 16);
            labLvl.setForeground(Color.white);
            labLvl.setFont(UIUtils.TEXT_FONT1);
            this.add(labLvl);
        }
        return labLvl;
    }

    public void setLabLvl(JLabel labLvl) {
        this.labLvl = labLvl;
    }

    public JLabel getLabUpLvl() {
        if (labUpLvl == null) {
            labUpLvl = new JLabel();
            	labUpLvl.setBounds(286, 29, 40, 16);
            labUpLvl.setForeground(Color.white);
            labUpLvl.setFont(UIUtils.TEXT_FONT1);
            this.add(labUpLvl);
        }
        return labUpLvl;
    }

    public void setLabUpLvl(JLabel labUpLvl) {
        this.labUpLvl = labUpLvl;
    }

    public JLabel getLabNeedExp() {
        if (labNeedExp == null) {
            labNeedExp = new JLabel();
            	labNeedExp.setBounds(188, 89, 127, 16);
            labNeedExp.setForeground(Color.white);
            labNeedExp.setFont(UIUtils.TEXT_FONT1);
            this.add(labNeedExp);
        }
        return labNeedExp;
    }

    public void setLabNeedExp(JLabel labNeedExp) {
        this.labNeedExp = labNeedExp;
    }

    public JLabel getLabHaveExp() {
        if (labHaveExp == null) {
            labHaveExp = new JLabel();
            	labHaveExp.setBounds(188, 115, 127, 16);
            labHaveExp.setForeground(Color.white);
            labHaveExp.setFont(UIUtils.TEXT_FONT1);
            this.add(labHaveExp);
        }
        return labHaveExp;
    }

    public void setLabHaveExp(JLabel labHaveExp) {
        this.labHaveExp = labHaveExp;
    }

    public JLabel getLabNeedGoog() {
        if (labNeedGoog == null) {
            labNeedGoog = new JLabel();
            	labNeedGoog.setBounds(188, 141, 127, 16);
            labNeedGoog.setForeground(Color.white);
            labNeedGoog.setFont(UIUtils.TEXT_FONT1);
            this.add(labNeedGoog);
        }
        return labNeedGoog;
    }

    public void setLabNeedGoog(JLabel labNeedGoog) {
        this.labNeedGoog = labNeedGoog;
    }

    public JLabel getLabHaveGoog() {
        if (labHaveGoog == null) {
            labHaveGoog = new JLabel();
            	labHaveGoog.setBounds(188, 167, 127, 16);
            labHaveGoog.setForeground(Color.white);
            labHaveGoog.setFont(UIUtils.TEXT_FONT1);
            this.add(labHaveGoog);
        }
        return labHaveGoog;
    }

    public void setLabHaveGoog(JLabel labHaveGoog) {
        this.labHaveGoog = labHaveGoog;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public ImageIcon getIcon() {
        return icon;
    }

    public void setIcon(ImageIcon icon) {
        this.icon = icon;
    }

    public FactionBtn getBtnPractice() {
        if (btnPractice == null) {
        		btnPractice = new FactionBtn("skin/8100226/newbutton/B22.png", 1, UIUtils.COLOR_BLACK, "修炼", UIUtils.TEXT_HY16,
                        24, this);
                btnPractice.setBounds(146, 250, 99, 24);
            this.add(btnPractice);
        }
        return btnPractice;
    }

    public void setBtnPractice(FactionBtn btnPractice) {
        this.btnPractice = btnPractice;
    }

    public int getMenuType() {
        return menuType;
    }

    public void setMenuType(int menuType) {
        this.menuType = menuType;
    }

}
